package ink.onei.common.aop;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;

import static ink.onei.common.constant.Constants.*;

/**
 * @Author: nekotako
 * @Description: TODO
 * @Date: 13/02/2024 23:30 Tuesday
 */
@Aspect
public class Enhance {
    @Pointcut("@annotation(ink.onei.common.aop.Tag)")
    private void anno() {
    }
    @Before("anno() && @annotation(tag)")
    public void before(JoinPoint joinPoint, Tag tag) {
        if (tag.type().isEmpty()) {
        }
    }

    @Before("anno() && @annotation(tag)")
    public void format(JoinPoint joinPoint, Tag tag) {
        if (tag.type().equals("Format")) {
            String fileType = (String) joinPoint.getArgs()[0];
            if (fileType.equals(BOBO_TYPE) ||
                fileType.equals(CHAT_TYPE) ||
                fileType.equals(GOODS_TYPE) ||
                fileType.equals(AVATAR_TYPE))
                fileType = "images/" + fileType;
            else fileType = CLOUD_ETC;
        }
    }
}
